home *** CD-ROM | disk | FTP | other *** search
- Path: news.iag.net!news
- From: jatmon@iag.net (John R Buchan)
- Newsgroups: comp.lang.c
- Subject: Re: Splitting String ?
- Date: 14 Jan 1996 20:07:11 GMT
- Organization: Internet Access Group, Orlando, Florida
- Message-ID: <4dbnpf$47c@news.iag.net>
- References: <DL3u9M.9xt@rci.ripco.com>
- NNTP-Posting-Host: pm3-orl13.iag.net
- X-Newsreader: WinVN 0.99.7
-
- In article <DL3u9M.9xt@rci.ripco.com>, mambuhl@ripco.com says...
- ->
- ->hakola@cadmail.hut.fi (Petri Hakola) in
- -><HAKOLA.96Jan12151128@jung.hut.fi> asks:
- ->
- ->
- ->> Have I missed something (again:) or why doesn't this code
- ->> work? I should split dos-a-like-filename and add new postfix
- ->> instead of old one (i.e. DATA.TXT --> DATA.UPD It seems to
- ->> work correctly if the filename has an old postfix, but if
- ->> there isn't one start won't return what it should.
- ->
- ->> - P -
- ->
- ->I may have missed something here, too. Your code [at EOM] seems to work
- ->for me. However, it looks like you do a lot of extra work that may be
- ->obscuring the problem. Why not start with a replacement for newname
- ->that looks like the following and see if it satisfies your needs:
- ->
- ->char *newname(char *s)
- ->{
- ->
- -> char *dot;
- -> dot = strchr(s, '.');
- -> if (dot)
- -> *dot = '\0';
- -> strcat(s, ".UPD");
- -> return s;
- ->}
-
- Unless I'm misssing something, this isn't going to work (safely or maybe at
- all), if he passes in the same string literals.
-
- ->>main() {
- ->> printf("%s\n",newname("LONGNAME.TXT"));
- ->> printf("%s\n",newname("NOEND"));
- ->>}
-
- --
- John R Buchan -:|:- Looking for that elusive FAQ? ftp to:
- jatmon@mail.iag.net -:|:- rtfm.mit.edu /pub/usenet-by-group/....
-
-